<?php

namespace App\Http\Requests\Sms;

use App\Enums\SmsEnum;
use App\Http\Requests\AbstractBaseRequest;
use Illuminate\Validation\Rule;

class SendRequest extends AbstractBaseRequest
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        $rules = [
            'send_key' => ['required', 'string', Rule::in(SmsEnum::$sendKeys)],
            'platform' => ['required', 'integer',Rule::in(SmsEnum::$platforms)],
            'mobile' => [Rule::requiredIf(in_array($this->send_key,[SmsEnum::REGISTER_CODE,SmsEnum::FIND_PASSWORD,SmsEnum::ADMIN_LOGIN_CODE]))],
        ];

        return $rules;
    }

    public function attributes(): array
    {
        return [
            'mobile' => trans('手机号'),
            'send_key' => trans('模板标识'),
            'platform' => trans('设备类型'),
        ];
    }
}
